package org.osomit.sacct.server.config.impl;

import org.osomit.sacct.server.config.iface.ServerConfig;
import com.google.inject.Singleton;
import com.google.inject.Inject;
import com.google.inject.name.Named;

/**
 * @author Jian Fang (John.Jian.Fang@gmail.com)
 *
 * Date: Jul 1, 2009
 */
@Singleton
public class ServerConfigImpl implements ServerConfig {

    private boolean useOTP = false;

    private String accountFileName = "accounts.reg";

    private int serverPort = 9000;

    private int poolSize = 12;

    private int randomIdLength = 12;

    private int maxSessionNum = 100;

    private int numToCleanSession = 25;

    private String sessionExpirationPolicy = "IdleTimeout";

    private long idletimeInMilliSeconds = 3000000;

    public String getSessionExpirationPolicy() {
        return sessionExpirationPolicy;
    }

    public long getIdletimeInMilliSeconds() {
        return idletimeInMilliSeconds;
    }

    public boolean isUseOTP() {
        return useOTP;
    }

    @Inject(optional=true)
    public void setUseOTP(@Named("useOTP") boolean useOTP) {
        this.useOTP = useOTP;
    }

    @Inject(optional=true)
    public void setIdletimeInMilliSeconds(@Named("idletimeInMilliSeconds") long idletimeInMilliSeconds) {
        this.idletimeInMilliSeconds = idletimeInMilliSeconds;
    }

    @Inject(optional=true)
    public void setSessionExpirationPolicy(@Named("sessionExpirationPolicy") String sessionExpirationPolicy) {
        this.sessionExpirationPolicy = sessionExpirationPolicy;
    }

    public int getMaxSessionNum() {
        return maxSessionNum;
    }

    @Inject(optional=true)
    public void setMaxSessionNum(@Named("maxSessionNum") int maxSessionNum) {
        this.maxSessionNum = maxSessionNum;
    }

    public int getNumToCleanSession() {
        return numToCleanSession;
    }

    @Inject(optional=true)
    public void setNumToCleanSession(@Named("numToCleanSession") int numToCleanSession) {
        this.numToCleanSession = numToCleanSession;
    }

    public String getAccountFileName() {
        return accountFileName;
    }

    @Inject(optional=true)
    public void setAccountFileName(@Named("accountFileName") String accountFileName) {
        this.accountFileName = accountFileName;
    }

    public int getServerPort() {
        return serverPort;
    }

    @Inject(optional=true)
    public void setServerPort(@Named("serverPort") int serverPort) {
        this.serverPort = serverPort;
    }

    public int getPoolSize() {
        return poolSize;
    }

    @Inject(optional=true)
    public void setPoolSize(@Named("poolSize") int poolSize) {
        this.poolSize = poolSize;
    }

    public int getRandomIdLength() {
        return this.randomIdLength;  
    }

    @Inject(optional=true)
    public void setRandomIdLength(@Named("randomIdLength") int randomIdLength) {
        this.randomIdLength = randomIdLength;
    }
}
